import hyRequest from '..'

// 用户的网络请求
export function postUserList(pageData: any) {
  return hyRequest.post({
    url: '/users/list',
    data: pageData
  })
}
// 查询某个用户
export function getUsers(id: number) {
  return hyRequest.post({
    url: `users/${id}`
  })
}
// 删除某个用户
export function deleteUsers(id: number) {
  return hyRequest.delete({
    url: `users/${id}`
  })
}
// 创建某个用户
export function foundUsers(userInfo: any) {
  return hyRequest.post({
    url: `/users`,
    data: userInfo
  })
}
// 修改某个用户
export function editUsers(id: number, userInfo: any) {
  return hyRequest.patch({
    url: `/users/${id}`,
    data: userInfo
  })
}

// 针对页面的网络请求
// 获取
export function pageListAction(pageName: string, userInfo: any) {
  return hyRequest.post({
    url: `/${pageName}/list`,
    data: userInfo
  })
}
// 新建
export function pageNewDataAction(pageName: string, userInfo: any) {
  return hyRequest.post({
    url: `/${pageName}`,
    data: userInfo
  })
}
// 删除
export function pageDeleteAction(pageName: string, id: number) {
  return hyRequest.delete({
    url: `/${pageName}/${id}`
  })
}
// 编辑
export function pageEditUserAction(pageName: string, id: number, userInfo: any) {
  console.log(userInfo)
  return hyRequest.patch({
    url: `/${pageName}/${id}`,
    data: userInfo
  })
}
